home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / c01lab5.zip / CRUISE / CODE / CRUISE.SPC < prev    next >
Text File  |  1992-03-17  |  6KB  |  164 lines

  1. with Automobile_Interface; use Automobile_Interface;
  2. -- **************************************************************
  3. -- *                                                            *
  4. -- *  Cruise                                                      *  SPEC
  5. -- *                                                            *
  6. -- **************************************************************
  7. package Cruise is -- package specification
  8. --|  Purpose
  9. --|  Cruise provides a set of functions and procedures which
  10. --|  implements a cruise control program.  Input function 
  11. --|  Fetch_Key requires the use of the "stty raw" command.  
  12. --|  After this command is entered, the "Return" key must be
  13. --|  implemented using "Cntl-J."  The terminal may be reset 
  14. --|  with the "stty -raw" command.  
  15. --|  This package implements a cruise control program using the
  16. --|  standard engage/disengage, set/resume cruise control 
  17. --|  functions.
  18.  
  19. type CC_SET_RESUME_ACTION is (SET, RESUME, UNSET);
  20. type ENGINE_ACTION is (ENGINE_OFF, ENGINE_ON);
  21. type CC_ENGAGED_ACTION is (ENGAGE, DISENGAGE);
  22. type CONTROLLER is (USER, CRUISE_CONTROL, USER_CRUISE);
  23. type PEDAL_ACTION is (RELEASE_PEDALS, DEPRESS_BRAKE, RELEASE_BRAKE, DEPRESS_ACCEL, HOLD_ACCEL, RELEASE_ACCEL);
  24.  
  25. subtype BRAKE_ACTION is PEDAL_ACTION range DEPRESS_BRAKE..RELEASE_BRAKE;
  26. subtype ACCEL_ACTION is PEDAL_ACTION range DEPRESS_ACCEL..RELEASE_ACCEL;
  27. subtype SET_RESUME is CC_SET_RESUME_ACTION range SET..RESUME;
  28. subtype AUTO_CC_FUNCTION is CHARACTER;   
  29.  
  30. --|  Global variables with initialization
  31. cc_set_resume_status : CC_SET_RESUME_ACTION := UNSET;
  32. cc_engaged_status : CC_ENGAGED_ACTION := DISENGAGE;
  33. engine_status : ENGINE_ACTION := ENGINE_OFF;
  34. auto_controller : CONTROLLER := USER;
  35. pedal_operation : PEDAL_ACTION := RELEASE_PEDALS;
  36. brake_status : BRAKE_ACTION := RELEASE_BRAKE;
  37. accel_status : ACCEL_ACTION := RELEASE_ACCEL;
  38. desired_speed : SPEED := 0.0;
  39. key : CHARACTER := ' ';
  40. quit : BOOLEAN := FALSE;
  41.  
  42. --...............................................................
  43. --.                                                                .
  44. --.  Cruise.Decode_Function                                        .
  45. --.                                                                .
  46. --...............................................................
  47. procedure Decode_Function (func : AUTO_CC_FUNCTION);
  48. --|  Purpose
  49. --|  Decode input function requested by user.  This procedure
  50. --|  calls the appropriate update procedure.
  51.  
  52. --...............................................................
  53. --.                                                                .
  54. --.  Cruise.Update_Pedal_Status                                    .
  55. --.                                                                .
  56. --...............................................................
  57. procedure Update_Pedal_Status (pedal : PEDAL_ACTION);
  58. --|  Purpose
  59. --|  Update global variables pedal_operation, brake_status, and
  60. --|  accel_status to the current action requested.
  61.  
  62. --...............................................................
  63. --.                                                                .
  64. --.  Cruise.Update_Engine_Status                                .
  65. --.                                                                .
  66. --...............................................................
  67. procedure Update_Engine_Status (engine : ENGINE_ACTION);
  68. --|  Purpose
  69. --|  Update global variable engine_status to the engine action
  70. --|  requested.
  71.  
  72. --...............................................................
  73. --.                                                                .
  74. --.  Cruise.Update_CC_Set_Resume_Status                            .
  75. --.                                                                .
  76. --...............................................................
  77. procedure Update_CC_Set_Resume_Status (CC_set_action : CC_SET_RESUME_ACTION);
  78. --|  Purpose
  79. --|  Update global variable cc_set_resume_status to the 
  80. --|  set/resume action  
  81.  
  82. --...............................................................
  83. --.                                                                .
  84. --.  Cruise.Update_CC_Engaged_Status                             .
  85. --.                                                                .
  86. --...............................................................
  87. procedure Update_CC_Engaged_Status (CC_engage_action : CC_ENGAGED_ACTION);
  88. --|  Purpose
  89. --|  Update global variable cc_engaged_status to the engaged
  90. --|  action.
  91.  
  92. --...............................................................
  93. --.                                                                .
  94. --.  Cruise.Print_Menu                                             .
  95. --.                                                                .
  96. --...............................................................
  97. procedure Print_Menu;
  98. --|  Purpose
  99. --|  Print user menu once when program begins.
  100.  
  101. --...............................................................
  102. --.                                                                .
  103. --.  Cruise.Format_Display                                        .
  104. --.                                                                .
  105. --...............................................................
  106. procedure Format_Display    (speed_value    : SPEED; 
  107.                             engine_text     : in STRING;
  108.                             brake_text      : in STRING;
  109.                             accel_text      : in STRING;
  110.                             engaged_text    : in STRING;
  111.                             set_resume_text : in STRING);
  112. --|  Purpose
  113. --|  Format output for display.  
  114.  
  115. --...............................................................
  116. --.                                                                .
  117. --.  Cruise.Determine_Control                                    .
  118. --.                                                                .
  119. --...............................................................
  120. procedure Determine_Control;
  121. --|  Purpose
  122. --|  Determine if cruise control or user is regulating the
  123. --|  automobile speed
  124.  
  125. --...............................................................
  126. --.                                                                .
  127. --.  Cruise.Fetch_Key                                            .
  128. --.                                                                .
  129. --...............................................................
  130. function Fetch_Key return BOOLEAN;
  131. --|  Purpose
  132. --|  Fetch user input
  133.  
  134. --...............................................................
  135. --.                                                                .
  136. --.  Cruise.Maintain_Speed                                        .
  137. --.                                                                .
  138. --...............................................................
  139. procedure Maintain_Speed;
  140. --|  Purpose
  141. --|  Maintain automobile speed at desired speed.
  142.  
  143. --...............................................................
  144. --.                                                                .
  145. --.  Cruise.Perform_Auto_Function                                .
  146. --.                                                                .
  147. --...............................................................
  148. procedure Perform_Auto_Function;
  149. --|  Purpose
  150. --|  Apply the desired automobile function using package
  151. --|  Automobile_Interface.
  152.  
  153. --...............................................................
  154. --.                                                                .
  155. --.  Cruise.Update_Dashboard                                    .
  156. --.                                                                .
  157. --...............................................................
  158. procedure Update_Dashboard;
  159. --|  Purpose
  160. --|  Update output text to correspond to current automobile state.
  161.  
  162.  
  163. end Cruise;
  164.